/**
 * Definition for a point.
 * class Point {
 *     int x;
 *     int y;
 *     Point() { x = 0; y = 0; }
 *     Point(int a, int b) { x = a; y = b; }
 * }
 */
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

public class Solution {
    public int maxPoints(Point[] points) {
        if(points == null || points.length == 0) {
            return 0;
        }

        Map<Double, Integer> map = new HashMap<>();
        int max = 1;
        for(int i = 0; i < points.length; i++) {
            map.clear();
            map.put((double) Integer.MIN_VALUE, 1);

            int same = 0;
            for(int j = i + 1; j < points.length; j++) {
                if(points[j].x == points[i].x && points[j].y == points[i].y) {
                    same++;
                } else {
                    double key = points[j].x - points[i].x == 0 ? Integer.MAX_VALUE :
                            0.0 + (points[j].y - points[i].y) * 1.0 / (points[j].x - points[i].x);
                    map.put(key, map.getOrDefault(key, 1) + 1);
                }
            }
            for(int temp : map.values()) {
                max = Math.max(max, temp + same);
            }
        }
        return max;
    }
}